package WWW.SST.LIB;

/** 
 Ticket ��ժҪ˵����
*/
public class Ticket extends MOLE.App.Every
{
		public int Tid = 0;
		public boolean IsExist = false;
		public String Number = "";
		public int Beishor = 0;
		public int Zhushor = 0;
		public String Term = "";
		public int Type;
		public int Uid = 0;
		public boolean IsZhweihaor = false;
		public boolean IsShowPrint = false;
		public String TypeStr = "";
		public String Gid = "";

	public Ticket()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}

	public Ticket(Object tid)
	{
		Tid = (Integer)tid;

		String s = "select * from daigou where id=" + String.valueOf(Tid);
		DataTable d = MOLE.SQL.GetDataTable(s);
		if (d.Rows.size() != 0)
		{
			this.IsExist = true;

		}

	}

	public static String getTicketByTerm(String termno)
	{
		String TicketIds = "";
	   String s = "exec Lotto_ListByTerm '" + termno + "'";
		DataTable d = MOLE.SQL.GetDataTable(s);
		for (int i = 0;i < d.Rows.size();i++)
		{
			TicketIds += d.Rows[i]["id"].toString().trim() + ",";
		}
		TicketIds = tangible.DotNetToJavaStringHelper.trim(TicketIds, ',');
		return TicketIds;

	}

	public static String FT_GetTicketToSend(String termno)
	{
		String TicketIds = "";
		String s = "exec spFT_GetSendTicket '" + termno + "'";
		DataTable d = MOLE.SQL.GetDataTable(s);
		for (int i = 0;i < d.Rows.size();i++)
		{
			TicketIds += d.Rows[i]["tid"].toString().trim() + ",";
		}
		TicketIds = tangible.DotNetToJavaStringHelper.trim(TicketIds, ',');
		return TicketIds;

	}


	public final void Bet()
	{
		// exec Lotto_Bet  'ssthz2s','20070505-10',5,1,861109,1,0
		/*
		CREATE PROCEDURE Lotto_Bet 
(
@type nvarchar(200), --'sisitsai hezhi 3syen,ssthz3s'
@term nvarchar(200),
@number nvarchar(200),
@beishor int,

@uid int, 
@isZhweihaor int,
@isPrintShow int
 if (xinji==3)tmp=;}	if (xinji==2)	{tmp=50120006;	} 
)
*/
		MOLE.SQLOS o = new MOLE.SQLOS("Lotto_Bet");
		o.RS(this.TypeStr);
		o.RS(this.Term);
		o.RS(this.Number);
		o.RS(this.Beishor);
		o.RS(this.Uid);
		if (this.IsZhweihaor)
		{
			o.RS(1);
		}
		else
		{
			o.RS(0);
		}
		if (this.IsShowPrint)
		{
			o.RS(0);
		}
		else
		{
			o.RS(1);
		}
		o.RS(this.Gid);

		 DataTable d = o.ExecStoreProcess();
		this.CODE = d.Rows[0]["code"].toString();
		this.CODEMSG = d.Rows[0]["msg"].toString();
	}
	public final void Print()
	{
		if (this.IsExist == false)
		{
			this.StausCode = 1;
			this.StausMsg = "not is exist";
			return;
		}
		MOLE.SQLOS o = new MOLE.SQLOS("Lotto_PrintTicket");
		o.RS(this.Tid);
		DataTable d = o.ExecStoreProcess();
		this.StausMsg = d.Rows[0]["result"].toString();
		if (this.StausMsg.toLowerCase().equals("ok"))
		{
			this.StausCode = 0;
		}
		else
		{
			this.StausCode = 1;
		}
	}

	public final void Print(String type)
	{
		if (!type.equals("ft")) //ftsai zhonsyend
		{
			Print();
			return;
		}



		if (this.IsExist == false)
		{
			this.StausCode = 1;
			this.StausMsg = "not is exist";
			return;
		}

		//ft zhonsyen
		MOLE.SQLOS o = new MOLE.SQLOS("spFT_chwpyao");
		o.RS(this.Tid);
		o.RS("auto");
		DataTable d = o.ExecStoreProcess();
		this.StausMsg = d.Rows[0]["result"].toString();
		if (this.StausMsg.toLowerCase().equals("ok"))
		{
			this.StausCode = 0;
		}
		else
		{
			this.StausCode = 1;
		}
	}

	public final void Giveup()
	{
		if (this.IsExist == false)
		{
			this.StausCode = 1;
			this.StausMsg = "TID:" + String.valueOf(this.Tid) + "������";
			return;
		}


		MOLE.SQLOS o = new MOLE.SQLOS("Lotto_giveup");
		o.RS(this.Tid);
		DataTable d = o.ExecStoreProcess();
		this.CODE = d.Rows[0]["code"].toString();
		this.CODEMSG = d.Rows[0]["msg"].toString();

	}

	public final void Giveup(String type)
	{

		if (type.equals("user"))
		{
			if (this.IsExist == false)
			{
				this.StausCode = 1;
				this.StausMsg = "TID:" + String.valueOf(this.Tid) + "������";
				return;
			}
			MOLE.SQLOS o = new MOLE.SQLOS("Lotto_giveup");
			o.RS(this.Tid);
			o.RS(1);
			DataTable d = o.ExecStoreProcess();
			this.CODE = d.Rows[0]["code"].toString();
			this.CODEMSG = d.Rows[0]["msg"].toString();
		}

		else if (type.equals("ft"))
		{
			if (this.IsExist == false)
			{
				this.StausCode = 1;
				this.StausMsg = "TID:" + String.valueOf(this.Tid) + "������";
				return;
			}
			MOLE.SQLOS o = new MOLE.SQLOS("spFT_Giveup");
			o.RS(this.Tid);
			DataTable d = o.ExecStoreProcess();
			this.CODE = d.Rows[0]["code"].toString();
			this.CODEMSG = d.Rows[0]["msg"].toString();
		}

		else
		{
			Giveup();
			return;
		}


	}


	public final void Giveup(String oser, int type)
	{
		try
		{
			MOLE.SQLOS o = new MOLE.SQLOS("spTicket_Giveup");
			o.RS(this.Tid);
			o.RS(oser);
			o.RS(type);
			DataTable d = o.ExecStoreProcess();
			this.CODE = d.Rows[0]["code"].toString();
			this.CODEMSG = d.Rows[0]["msg"].toString();
		}
		catch (RuntimeException ee)
		{
			this.CODE = "codeerr";
			this.CODEMSG = "ϵͳ����";
		}

	}
	public final void _AutoP()
	{
		MOLE.SQLOS o = new MOLE.SQLOS(" Lotto_PrintTicket_AutoP");
		DataTable d = o.ExecStoreProcess();
		this.CODE = d.Rows[0]["code"].toString();
		this.CODEMSG = d.Rows[0]["msg"].toString();

	}


}